package com.whfc.fuum.service.impl;

import com.whfc.common.exception.BizException;
import com.whfc.fuum.dao.SysUserCodeMapper;
import com.whfc.fuum.dto.SysUserCodeDTO;
import com.whfc.fuum.entity.SysUserCode;
import com.whfc.fuum.service.SysUserCodeService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author qzexing
 * @version 1.0
 * @date 2020-12-11 16:20
 */
@DubboService(interfaceClass = SysUserCodeService.class, version = "1.0.0")
public class SysUserCodeServiceImpl implements SysUserCodeService {

    @Autowired
    private SysUserCodeMapper sysUserCodeMapper;

    @Override
    public void addUserCode(SysUserCodeDTO sysUserCodeDTO) throws BizException {
        SysUserCode sysUserCode = new SysUserCode();
        sysUserCode.setCode(sysUserCodeDTO.getCode());
        sysUserCode.setExpiresIn(sysUserCodeDTO.getExpiresIn());
        sysUserCode.setExpireTime(sysUserCodeDTO.getExpireTime());
        sysUserCode.setUsername(sysUserCodeDTO.getUsername());
        sysUserCode.setExpireFlag(sysUserCodeDTO.getExpireFlag());
        sysUserCodeMapper.insertSelective(sysUserCode);
    }

    @Override
    public SysUserCodeDTO selectByCode(String code) throws BizException {
        return sysUserCodeMapper.selectByCode(code);
    }
}
